class Session:
    def __init__(self, name=None, check_hit_func=None):
        self.name = name
        self.check_hit_func = check_hit_func
        self.session_id = None

    def __enter__(self):
        # 初始化会话
        self.session_id = self._generate_session_id()
        print(f"Session {self.session_id} started.")
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        # 清理会话
        print(f"Session {self.session_id} ended.")
        self.session_id = None

    def _generate_session_id(self):
        # 生成一个唯一的会话ID
        import uuid
        return str(uuid.uuid4())

# 使用示例
with Session() as session:
    print("Inside the session")
    # 在会话上下文中执行查询或其他操作
